package com.lcf.system.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.lcf.framework.vo.PageVO;
import com.lcf.system.dto.SysTenantRuleDTO;
import com.lcf.system.query.SysTenantRulePageQuery;
import com.lcf.system.service.SysTenantRuleService;
import com.lcf.system.vo.SysTenantRulePageVO;
import com.lcf.system.vo.SysTenantRuleVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 团购规则(SysTenantRule)表控制层
 *
 * @author lcf
 * @since 2025-05-02 11:55:03
 */
@Tag(name = "团购规则")
@RestController
@RequestMapping("sysTenantRule")
public class SysTenantRuleController {
    @Resource
    private SysTenantRuleService sysTenantRuleService;

    /**
     * 新增
     */
    @Operation(summary = "新增")
    @SaCheckPermission({"sysTenantRule:add"})
    @PostMapping
    public boolean save(@RequestBody @Validated SysTenantRuleDTO dto) {
        return sysTenantRuleService.save(dto);
    }

    /**
     * 修改
     */
    @Operation(summary = "修改")
    @SaCheckPermission({"sysTenantRule:update"})
    @PatchMapping("/{id}")
    public boolean update(@PathVariable @Schema(description = "主键") long id,
                          @RequestBody @Validated SysTenantRuleDTO dto) {
        return sysTenantRuleService.update(id, dto);
    }

    /**
     * 删除
     */
    @Operation(summary = "删除")
    @SaCheckPermission({"sysTenantRule:remove"})
    @DeleteMapping("/{id}")
    public boolean remove(@PathVariable @Schema(description = "主键") long id) {
        return sysTenantRuleService.remove(id);
    }

    /**
     * 获取详情
     */
    @Operation(summary = "获取详情")
    @SaCheckPermission({"sysTenantRule:getDetail"})
    @GetMapping("/{id}")
    public SysTenantRuleVO getDetail(@PathVariable @Schema(description = "主键") long id) {
        return sysTenantRuleService.getDetail(id);
    }

    /**
     * 分页
     */
    @Operation(summary = "分页")
    @SaCheckPermission({"sysTenantRule:page"})
    @GetMapping("page")
    public PageVO<SysTenantRulePageVO> page(SysTenantRulePageQuery query) {
        return sysTenantRuleService.page(query);
    }
}

